package com.graduation.books_borrow.repository;

import com.graduation.books_borrow.entity.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BooksQueryMapper {

    @Select("select id, book_name, author, status, addtime, comment from books where status = 1")
    List<Book> booksQuery();

    @Select("select id, book_name, author, status, addtime, comment from books where status = 1 and book_name = #{bookName}")
    List<Book> booksQueryByName(Book book);

    @Select("select id, book_name, author, status, addtime, comment from books where status = 1 and author = #{author}")
    List<Book> booksQueryByAuthor(Book book);

    @Select("select id, book_name, author, status, addtime, comment from books where status = 1 and book_name = #{bookName} and author = #{author}")
    List<Book> booksQueryByNameAuthor(Book book);

    @Select("select id, book_name, author, status, addtime, comment from books where status = 1 and id = #{id} limit 1")
    Book booksQueryById(@Param("id") Integer id);


}
